<?php


function mylinks_feednew($limit=0, $offset=0)
{
	global $xoopsDB;
	global $mydirname;
	$myts =& MyTextSanitizer::getInstance();

	if (isset($_GET['cid'])) { 
	$categoryid = intval($_GET['cid']);
	$sql = "SELECT l.lid, l.title as ltitle, l.date, l.cid, l.submitter, l.hits, t.description, c.title as ctitle FROM ".$xoopsDB->prefix($mydirname."_links")." l, ".$xoopsDB->prefix($mydirname."_text")." t, ".$xoopsDB->prefix($mydirname."_cat")." c WHERE l.cid= ".$categoryid." AND t.lid=l.lid AND l.cid=c.cid AND l.status>0 ORDER BY l.date DESC";
	}
	else {
	$sql = "SELECT l.lid, l.title as ltitle, l.date, l.cid, l.submitter, l.hits, t.description, c.title as ctitle FROM ".$xoopsDB->prefix($mydirname."_links")." l, ".$xoopsDB->prefix($mydirname."_text")." t, ".$xoopsDB->prefix($mydirname."_cat")." c WHERE t.lid=l.lid AND l.cid=c.cid AND l.status>0 ORDER BY l.date DESC";
	}
	$URL_MOD = XOOPS_URL."/modules/".$mydirname;

	$result = $xoopsDB->query($sql,$limit,$offset);

	$i = 0;
	$ret = array();

 	while($row = $xoopsDB->fetchArray($result))
 	{
		$ret[$i]['link']     = $URL_MOD."/singlelink.php?lid=".$row['lid'];
		$ret[$i]['cat_link'] = $URL_MOD."/viewcat.php?cid=".$row['cid'];

		$ret[$i]['title'] = $row['ltitle'];
		$ret[$i]['time']  = $row['date'];
//		$ret[$i]['description'] = $row['description'];

// atom feed
		$ret[$i]['id'] = $row['lid'];
		$ret[$i]['description'] = $myts->makeTareaData4Show( $row['description'], 0 );	//no html

// category
		$ret[$i]['cat_name'] = $row['ctitle'];

// counter
		$ret[$i]['hits'] = $row['hits'];

// this module dont show user name
//		$ret[$i]['uid'] = $row['submitter'];

		$i++;
	}

	return $ret;
}

?>